package com.socool.sinofaith.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.TextView;

import com.socool.sinofaith.R;

public class ProgressDialog extends Dialog {
	private TextView tv_msg;
	private String content;

	public ProgressDialog(Context context) {
		this(context, "正在载入中...");
	}

	public ProgressDialog(Context context, String content) {
		super(context, R.style.progress_dialog);
		this.content = content;

	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_wait);
		this.setCancelable(true);
		this.getWindow().setBackgroundDrawableResource(
				android.R.color.transparent);
		this.setCanceledOnTouchOutside(false); // 设置点击屏幕dialog不消失
		tv_msg = (TextView) this.findViewById(R.id.tv_loadingmsg);
		tv_msg.setText(content + "");

	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
			return true;
		}
		if (keyCode == KeyEvent.KEYCODE_SEARCH) {
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	public void show(String content) {
		this.content = content;
		this.show();
	}

	public void setText(String text) {
		this.tv_msg.setText(text);
	}

}
